﻿using Microsoft.VisualStudio.TestTools.UnitTesting;
using Rhino.Mocks;

namespace Ewk.Math.Algebra.UnitTests.MatrixTests.DoubleTests
{
    [TestClass]
    public class RankTests : DoubleTestBase
    {
        [TestMethod]
        public void MatrixDouble_Rank_uses_an_IRankComputer_Only_once_to_compute_the_rank_of_the_matrix_and_returns_the_value_that_is_returned_by_the_IRankComputer()
        {
            var matrix1 = Identity;

            const int mockedRank = 8; // Yes, this is an incorrect value

            RankComputer
                .Expect(
                    computer =>
                    computer.ComputeRank(matrix1))
                .Return(mockedRank)
                .Repeat.Once();
            RankComputer.Replay();

            var rank1 = matrix1.Rank;
            var rank2 = matrix1.Rank;

            Assert.AreEqual(mockedRank, rank1);
            Assert.AreEqual(mockedRank, rank2);

            RankComputer.VerifyAllExpectations();
        }
    }
}